package com.homejoy.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homejoy.common.annotation.Log;
import com.homejoy.common.core.controller.BaseController;
import com.homejoy.common.core.domain.AjaxResult;
import com.homejoy.common.enums.BusinessType;
import com.homejoy.system.domain.HomejoyPropertyAudit;
import com.homejoy.system.service.IHomejoyPropertyAuditService;
import com.homejoy.common.utils.poi.ExcelUtil;
import com.homejoy.common.core.page.TableDataInfo;

/**
 * 房源审核记录Controller
 *
 * @author homeJoy
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/system/audit")
public class HomejoyPropertyAuditController extends BaseController {
    @Autowired
    private IHomejoyPropertyAuditService homejoyPropertyAuditService;

    /**
     * 查询房源审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomejoyPropertyAudit homejoyPropertyAudit) {
        startPage();
        List<HomejoyPropertyAudit> list = homejoyPropertyAuditService.selectHomejoyPropertyAuditList(homejoyPropertyAudit);
        return getDataTable(list);
    }

    /**
     * 导出房源审核记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:audit:export')")
    @Log(title = "房源审核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomejoyPropertyAudit homejoyPropertyAudit) {
        List<HomejoyPropertyAudit> list = homejoyPropertyAuditService.selectHomejoyPropertyAuditList(homejoyPropertyAudit);
        ExcelUtil<HomejoyPropertyAudit> util = new ExcelUtil<HomejoyPropertyAudit>(HomejoyPropertyAudit.class);
        util.exportExcel(response, list, "房源审核记录数据");
    }

    /**
     * 获取房源审核记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:audit:query')")
    @GetMapping(value = "/{auditId}")
    public AjaxResult getInfo(@PathVariable("auditId") Long auditId) {
        return success(homejoyPropertyAuditService.selectHomejoyPropertyAuditByAuditId(auditId));
    }

    /**
     * 新增房源审核记录
     */
    @PreAuthorize("@ss.hasPermi('system:audit:add')")
    @Log(title = "房源审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomejoyPropertyAudit homejoyPropertyAudit) {
        return toAjax(homejoyPropertyAuditService.insertHomejoyPropertyAudit(homejoyPropertyAudit));
    }

    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('system:audit:edit')")
    @Log(title = "房源审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomejoyPropertyAudit homejoyPropertyAudit) {
        return toAjax(homejoyPropertyAuditService.auditHomeJoyProperty(homejoyPropertyAudit));
    }

    /**
     * 删除房源审核记录
     */
    @PreAuthorize("@ss.hasPermi('system:audit:remove')")
    @Log(title = "房源审核记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{auditIds}")
    public AjaxResult remove(@PathVariable Long[] auditIds) {
        return toAjax(homejoyPropertyAuditService.deleteHomejoyPropertyAuditByAuditIds(auditIds));
    }
}
